<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class tipoftheday extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function __construct() {
		parent::__construct();
		ini_set('session.cookie_httponly',1); 
		ini_set('session.use_only_cookies',1);
		$this->load->model('tipoftheday_class');
	}	 

	public function get_tipoftheday(){
		$post = $this->input->post();
		$tipoftheday = $this->tipoftheday_class->get_tipoftheday($post);
		echo json_encode($tipoftheday);
	}

	public function save_tipoftheday(){
		$post = $this->input->post();
		$message = '';
		$tipoftheday = $this->tipoftheday_class->list_tipoftheday($post);
		if($tipoftheday!=0){
			$message = $this->tipoftheday_class->update($post);
		}
		echo json_encode($message);
	}

	public function add_tipoftheday(){
		$post = $this->input->post();
		$message = '';
		$tipoftheday = $this->tipoftheday_class->list_tipoftheday($post);
		if($tipoftheday!=0){
			$message = $this->tipoftheday_class->insert($post);
		}
		echo json_encode($message);
	}

	public function list_tipoftheday(){
		$data=array();
	
		$diary = $this->tipoftheday_class->list_tipoftheday();
		if($diary!=0){
			foreach($diary as $key=>$value){
				$data['intID'][$key]=$value['intID'];
				$data['intNumDays'][$key]=$value['intNumDays'];
				$data['strNote'][$key]=$value['strNote'];
				$data['intFontSize'][$key]=$value['intFontSize'];
				$data['strImgLink'][$key]=$value['strImgLink'];
				$data['intDisabled'][$key]=$value['intDisabled'];
				$data['dateCreatedDate'][$key]=$value['dateCreatedDate'];
			}
		}
		echo json_encode($data);
	}	

	public function delete_tipoftheday(){
		$post = $this->input->post();
		$tipoftheday = $this->tipoftheday_class->delete($post);
		echo json_encode($tipoftheday);
	}	
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */